package com.atguigu.yygh.common.config;

import com.google.common.base.Predicates;
import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/*==========================================
      时 间:   2022-02-28
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@Configuration
@EnableSwagger2 //开启Swagger支持
public class SwaggerConfiguration {

    @Bean
    public Docket getDocketObject(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("admin").apiInfo(getAdminApiInfo()).select().paths(Predicates.and(PathSelectors.regex("/admin/.*"))).build();
    }

    @Bean
    public Docket getDocketObject1(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("user").apiInfo(getUserApiInfo()).select().paths(Predicates.and(PathSelectors.regex("/user/.*"))).build();
    }

    @Bean
    public Docket getDocketObject2(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("sms").apiInfo(getUserApiInfo()).select().paths(Predicates.and(PathSelectors.regex("/api/sms/.*"))).build();
    }
    @Bean
    public Docket getDocketObject4(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("userinfo").apiInfo(getUserApiInfo()).select().paths(Predicates.and(PathSelectors.regex("/api/userinfo/.*"))).build();
    }


    public ApiInfo getAdminApiInfo(){
        return new ApiInfo("管理员系统文档","当前文档提供的是管理员系统的接口文档","1.0","http://www.baidu.com",new Contact(null,null,"churenyi@163.com"),null,null,new ArrayList<VendorExtension>());
    }


    public ApiInfo getUserApiInfo(){
        return new ApiInfo("用户系统文档","当前文档提供的是用户系统的接口文档","1.0","http://www.baidu.com",new Contact(null,null,"churenyi@163.com"),null,null,new ArrayList<VendorExtension>());
    }
}
